<?php
/**
 * Pipahr
 * @author Randy Zhao
 * @copyright 2013 pipahr.com
 */
defined('_JEXEC') or die;

// disable core styles to avoid bs conflict
OC_Util::$core_styles = array();
$shareEvent = isset($_['shareEvent']) ? $_['shareEvent'] : '';
$startyear = isset($shareEvent['startdate']) ? JHtml::_('date', $shareEvent['startdate'], 'Y') : JHtml::_('date', PFactory::getDate(), 'Y');
$startmonth = isset($shareEvent['startdate']) ? intval(JHtml::_('date', $shareEvent['startdate'], 'm'))-1 : intval(JHtml::_('date', PFactory::getDate(), 'm'))-1;

if (isDevMode()) {
   // Style
   OCP\Util::addStyle('calendar', 'calendar');
   OCP\Util::addStyle('calendar', 'calendar.common');
   OCP\Util::addStyle('calendar', 'style');
   OCP\Util::addStyle('themes/jobs/core/js/jquery/fullcalendar', 'fullcalendar');
   OCP\Util::addStyle('themes/jobs/core/js/jquery/jquery-timepicker', 'jquery.timepicker');
   // Js
   OCP\Util::addscript('themes/jobs/core/js/jquery/fullcalendar', 'fullcalendar');
   OCP\Util::addscript('themes/jobs/core/js/jquery/jquery-timepicker', 'jquery.timepicker');
   OCP\Util::addscript('','oc-vcategories');
   OCP\Util::addscript('calendar', 'calendar');
   OCP\Util::addscript('calendar', 'calendar.common');
} else {
   OCP\Util::addStyle('static', 'calendar');
   OCP\Util::addScript('static', 'apps/calendar.calendar.min');
}
OCP\App::setActiveNavigationEntry('calendar_index');
?>
<script type="text/javascript" src="<?php print_unescaped(OC_Helper::linkTo('calendar/js', 'l10n.php'));?><?php echo is_array($shareEvent) ? '?share='.$shareEvent['token'].'&userid='.$shareEvent['userid'] : ''?>"></script>
<script type="text/javascript" src="<?php print_unescaped(OC_Helper::linkTo('calendar/js', 'calendar.php'));?>"></script>

<div id="notification" style="display:none;"></div>
<div class="hr_inner_navigate clearfix">
   <ul class="clearfix">
      <li class="cur_li"><a href="javascript:;" id="onemonthview_radio"><?php echo $l->t('Month');?></a></li>
      <li><a href="<?=OC_Helper::linkToRoute("calendar_list")?>"><?php echo $l->t('Custom List');?></a></li>
   </ul>

   <?php if ( !is_array($shareEvent) ) {
      ?>
      <div class="positionselect medium pull-left">
         <span>职位：</span>
         <div id="joblinks" class="comselectmenubox dropdown" pjobid="0">
            <span data-target="#" data-toggle="dropdown" class="needp_relative dropdown-toggle"><b>全部</b> <i></i></span>
            <div id="changejob" class="needp_absolute dropdown-menu">
               <a id="0" class="cur_a" href="">全部</a>
               <?php foreach ($_['joblists'] as $k => $job) {
               ?>
                  <a href="javascript:;" id="<?php echo $job['id'];?>"><?php echo $job['job_title'];?></a>
                  <?php if ( $k == 9 ): ?>
                     <a class="last_lookmore" href="javascript:;">查看更多</a>
                     <?php break;?>
                  <?php endif ?>
               <?php
               }?>
            </div>
         </div>
      </div>
      <div class="separated_line pull-left">|</div>
      <?php
   }?>

   <div class="calendar_selectaction pull-left">
      <div class="cald_prev" id="datecontrol_left"></div>
      <input type="button" class="hasDatepicker" value="" id="datecontrol_date"/>
      <div class="cald_todaydate yahei" id="today_input" style="display:none;">
         <?php echo $l->t("Today");?>
      </div>
      <div class="cald_next" id="datecontrol_right"></div>
      <img id="loading" src="<?php print_unescaped(OCP\Util::imagePath('core', 'loading.gif')); ?>" style="vertical-align:middle;" />
   </div>
   
   <?php if(OC_User::isLoggedIn()):?>
   <div class="pull-left caln_setinvite"><a href="javascript:;" id="caln_setinvite" class="ppp_bluebtn">安排面试</a></div>
   <?php endif; ?>

</div>
<input type="hidden" name="requesttoken" value="<?php echo $_['requesttoken'] ?>" id="requesttoken" />
<div id="fullcalendar" data-calid="<?php echo isset($_['calendarid']) ? $_['calendarid'] : 0;?>" data-share="<?php echo is_array($shareEvent) ? $shareEvent['token'] : '';?>" data-userid="<?php echo is_array($shareEvent) ? $shareEvent['userid'] : '';?>" data-startyear="<?=$startyear?>" data-startmonth="<?=$startmonth?>"></div>
<div id="dialog_holder"></div>
<div id="modal_holder" class="modal hide interviewtime_dialog" style="position:absolute;"></div>
<div id="preview_holder" class="modal changeinterview_dialog popup" style="display:none; max-width:500px; position:absolute; z-index:100;"></div>
<!--发offer的dialog-->
<div class="modal hide fade interviewtime_dialog" id="sendofferdialog" style="display:none; position:absolute;"></div>
<div class="modal interresult_dialog popup" id="interviewsuccess" style="display:none; position:absolute"></div>

<div class="modal hide fade searchinterview_dialog" id="searchinterview_dialog" style="position:absolute;">
</div>
<div id="event_modal" class="modal hide fade interviewtime_dialog" style="position:absolute;"></div>

<div class="modal hide fade getresult_dialog" id="getresult_dialog" style="position:absolute;">
   <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
      <h3>安排面试</h3>
   </div>
   <div class="modal-body">
      <div class="autosteparrow medium">
         <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
               <td width="20"><div class="autoarrow autoleft_yy"></div></td>
               <td><div class="autoword_yy">&nbsp;指定应聘者&nbsp;</div></td>
               <td width="27"><div class="autoarrow automid_yy"></div></td>
               <td><div class="autoword_yy">填写面试信息</div></td>
               <td width="27"><div class="autoarrow automid_yy"></div></td>
               <td><div class="autoword_yy">&nbsp;&nbsp;&nbsp;&nbsp;完成&nbsp;&nbsp;&nbsp;&nbsp;</div></td>
               <td width="19"><div class="autoarrow autoright_yy"></div></td>
            </tr>
         </table>
      </div>
      
      <div class="gresult_content"><span class="yahei"><i></i> 面试安排完成</span></div>
   </div>   
</div>
<?php if($_['objects_number'] <= 0):?>
<!--  重未安排过面试的提醒dialog -->
<div class="modal hide fade neverset_dialog" id="neverset_dialog" style="position:absolute;">
   <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
      <h3 class="yahei">安排面试日程，枇杷派云招聘会为您</h3>
   </div>
   <div class="modal-body">
      <div class="neverset_content">
         <div class="nvs_cwrapper clearfix">
            <i class="bg1 pull-left"></i>
            <div class="pull-left yahei">
               <p><span>通知应聘者</span>（面试时间，地点，路线）</p>
               <p><span>通知面试官</span>（面试时间，简历和面试反馈表）</p>
            </div>
         </div>

         <div class="nvs_cwrapper clearfix">
            <i class="bg2 pull-left"></i>
            <div class="pull-left yahei">
               <p>面试前一天，发送<span>面试提醒</span>给应聘者和面试官</p>
               <p>面试后，发送<span>反馈提醒</span>给面试官</p>
            </div>
         </div>

         <div class="nvs_setbtn"><a href="#" class="setbluebtn yahei">立即安排面试</a></div>
      </div>
   </div> 
</div>
<?php endif;?>